﻿//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//    Crolengi, this program (a part of program) is gameengine based on C++\Directx
//    Copyright (C) 2008 Pashinin Anton Alekseevich (Crol)
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.
//    (INCLUDING NEGLIGENCE OR OTHERWISE) 
//    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
//    EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//    Contacts: 
//    Mail: crolengi@gmail.com
//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once
#ifndef  Event_Manager_h
#define  Event_Manager_h

#include "..\\import\\CRLEngi_strings_lib\\CRLEngi_strings.h"
#include "..\\import\\param_trees_lib\\param_trees.h"
//#include "include\\Managers\\TimeLine.h"
#include "include\\Managers\\Camera_Manager.h"
#include "include\\Managers\\Object_Manager.h"
#include "include\\Utils\\Timer.h"
//#include "include\\Managers\\Resource_Maneger.h"

//#################################################################################################################
///// 
/////   :: КЛАСС МЕНЕДЖЕРА СОБЫТИЙ ::
///// 
//#################################################################################################################
class CLREngi_Event_Manager{
protected:
	/////////////// менеджеры
	CLREngi_Camera_Manager   *Camera_Manager;
	CLREngi_Object_Manager   *Object_Manager;

public:
	DynamicRow TimeLine;
	int mainID;
//#################################################################################################################
void    AnalyzeCommands(){
	  
	  if (TimeLine.NUM_LOADED>1){
		   int count = TimeLine.iCountParams(mainID);
		   for (int i=1;i<=count;i++){
	          int id2   = TimeLine.TopId(mainID);
			  if (id2!=0){
		             AnalyzeCommand(TimeLine.iLookName(id2));
                     TimeLine.DeleteById(id2);
					}
		      }
	       }
	  }
void    AnalyzeCommand(CRLEngi_string  Command){

       /// теперь анализ команды
	  CRLEngi_string  C1,C2;
	  Command.DivideTwoParameters(&C1,&C2);	

	   if (C1=="console"){
		   (*Object_Manager).text_to_console(C2,0);
	       }
	   else
	   if ((C1=="cam_mngr")||(C1=="camera_manager")){
		      (*Camera_Manager).AnalyzeCommand(C2);
	       }
	   else
	   if ((C1=="obj_mngr")||(C1=="object_manager")){
		      (*Object_Manager).AnalyzeCommand(C2);
	       }
	   else
		 (*Object_Manager).text_to_console(Command,2);

	   //AnalyzeCommands
      //....
	  
	 
}//void

void    AnalyzeCommand(char  *Cm){
	CRLEngi_string  Command;
	Command = Cm;

       /// теперь анализ команды
	  CRLEngi_string  C1,C2;
	  Command.DivideTwoParameters(&C1,&C2);	

	   if (C1=="console"){
		   (*Object_Manager).text_to_console(C2,0);
	       }
	   else
	   if ((C1=="cam_mngr")||(C1=="camera_manager")){
		      (*Camera_Manager).AnalyzeCommand(C2);
	       }
	   else
	   if ((C1=="obj_mngr")||(C1=="object_manager")){
		      (*Object_Manager).AnalyzeCommand(C2);
	       }
	   else
		 (*Object_Manager).text_to_console(Command,2);

	   //AnalyzeCommands
      //....
	  
	 
}//void

//#################################################################################################################
public:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                     КОНСТРУКТОР
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
CLREngi_Event_Manager(	CLREngi_Camera_Manager   *CManager,
	                    CLREngi_Object_Manager   *OManager){
	Camera_Manager = CManager;
	Object_Manager = OManager;

	TimeLine.fresh();
	mainID = TimeLine.AddToId(0,true,"TIME_LINE");
   };

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////                                                                                                    ДЕСТРУКТОР
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ~CLREngi_Event_Manager(void)
   {
   };

};

#endif 